package com.chensheng.config;

import com.lly835.bestpay.config.WxPayH5Config;
import com.lly835.bestpay.service.impl.BestPayServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

/**
 * @Author:ChenSheng
 * @Description:
 * @Date: Created in 下午 22:31 2018/5/16 0016
 */
@Component
public class WechatPayConfig {

    @Autowired
    private JWechatAccountConfig jWechatAccountConfig;

    @Bean
    public BestPayServiceImpl bestPayService(){
        BestPayServiceImpl bestPayService = new BestPayServiceImpl();
        bestPayService.setWxPayH5Config(wxPayH5Config());
        return bestPayService;
    }

    @Bean
    public WxPayH5Config wxPayH5Config(){
        WxPayH5Config wxPayH5Config = new WxPayH5Config();
        wxPayH5Config.setAppId(jWechatAccountConfig.getMpAppId());
        //wxPayH5Config.setAppSecret("0161b1d7eef0e086828952e83f7a96a6");
        wxPayH5Config.setMchId(jWechatAccountConfig.getMchId());
        wxPayH5Config.setMchKey(jWechatAccountConfig.getMchKey());
        wxPayH5Config.setNotifyUrl(jWechatAccountConfig.getNotifyUrl());
        wxPayH5Config.setKeyPath(jWechatAccountConfig.getKeyPath());

        return wxPayH5Config;
    }

}
